﻿using GrapeCity.Forguncy.CellTypes;
using GrapeCity.Forguncy.Commands;
using GrapeCity.Forguncy.Plugin;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Windows;
using Vant.Properties;
using Vant.WpfControls;
using Vant.WpfControls.DrawingObject;

namespace Vant.CellTypes
{
    public class CircleDesigner : CellTypeDesigner<Circle>
    {
        public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
        {
            var cellStyleViewModel = StyleHelper.CreateStyleViewModel(cellInfo, drawingHelper);
            return new CircleDrawingObject(this.CellType, cellStyleViewModel, cellInfo, drawingHelper);
        }
    }

    [Designer("Vant.CellTypes.CircleDesigner, Vant")]
    [Icon("pack://application:,,,/Vant;component/Resources/Images/Circle.png")]
    [OrderWeight((int)Utils.OrderWeight.Circle)]
    public class Circle : VantCellTypeBase, ICommandCellType, ISupportDefaultValue
    {
        [SRDisplayName(nameof(Resources.ValueChangeCommand))]
        public List<Command> CommandList { get; set; } = new List<Command>();

        public CommandExcuteKind CommandExcuteKind => CommandExcuteKind.OnValueChanged;

        [SRDisplayName(nameof(Resources.Vant_DefaultValue))]
        [FormulaProperty]
        public object DefaultValue { get; set; }

        [Browsable(false)]
        [JsonIgnore]
        public bool NeedFormatDefaultValue { get; set; } = true;

        [SRDisplayName(nameof(Resources.Progress_Text))]
        [FormulaProperty]
        public object text { get; set; }

        [SRDisplayName(nameof(Resources.Progress_Color))]
        [ColorProperty]
        public string color { get; set; } = "Accent 1";

        [SRDisplayName(nameof(Resources.Progress_LayerColor))]
        [ColorProperty]
        public string layerColor { get; set; } = "#e5e5e5";

        [SRDisplayName(nameof(Resources.Circle_Progress_Fill))]
        [ColorProperty(SupportNoFill = true)]
        public string fill { get; set; }

        [SRDisplayName(nameof(Resources.Circle_Progress_Size))]
        [IntProperty(Min = 1)]
        [DefaultValue(100)]
        public int size { get; set; } = 100;

        [SRDisplayName(nameof(Resources.Progress_StrokeWidth))]
        [IntProperty(Min = 1)]
        [DefaultValue(4)]
        public int strokeWidth { get; set; } = 4;

        [SRDisplayName(nameof(Resources.Circle_Progress_StrokeLinecap))]
        [SRComboProperty(ValueList = "round|square|butt", DisplayList = nameof(Resources.Circle_Progress_StrokeLinecap_DisplayList))]
        public string strokeLinecap { get; set; } = "round";

        [SRDisplayName(nameof(Resources.Circle_Progress_Speed))]
        [DefaultValue(0)]
        public int speed { get; set; } = 0;

        [SRDisplayName(nameof(Resources.Circle_Progress_StrokeLinecap_StartPosition))]
        [SRComboProperty(ValueList = "top|bottom|left|right", DisplayList = nameof(Resources.Circle_Progress_StrokeLinecap_StartPosition_DisplayList))]
        public string startPosition { get; set; } = "top";

        [SRCategoryHeader(nameof(Resources.Other))]
        [SRDisplayName(nameof(Resources.Circle_Progress_StrokeLinecap_Clockwise))]
        [DefaultValue(true)]
        public bool clockwise { get; set; } = true;

        [SRDisplayName(nameof(Resources.Progress_ChangeProgressStatus))]
        [RunTimeMethod]
        [SRDescription(nameof(Resources.Progress_ChangeProgressStatus))]
        public void ChangeCircleProgressStatus(
            [SRItemDisplayName(nameof(Resources.Progress_Text))]
            string text,

            [SRItemDisplayName(nameof(Resources.Progress_Color))]
            [ColorProperty(SupportNoFill = true)]
            string color,

            [SRItemDisplayName(nameof(Resources.Circle_Progress_Fill))]
            [ColorProperty(SupportNoFill = true)]
            string fill)
        {
            //
        }

        public override string ToString()
        {
            return Properties.Resources.Circle_Progress;
        }
    }
}
